home *** CD-ROM | disk | FTP | other *** search
/ Enter 2006 September / Enter 09 2006.iso / Internet / SpamExperts Home 1.1 / SpamExperts Home.exe / lib / spamexperts.modules / spamexperts / resources.pyc (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2006-07-14  |  2.6 KB  |  67 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.4)
  3.  
  4. '''
  5. This file holds information about files, such as paths to images
  6. and other resources stored on a file system.
  7. '''
  8. import os
  9. import sys
  10. from spamexperts.Options import options
  11. from win32com.shell import shell, shellcon
  12. images = {
  13.     'base splash screen': 'base_splash_screen.png',
  14.     'pro splash screen': 'pro_splash_screen.png',
  15.     'splash screen': 'splash_screen.bmp',
  16.     'logo-ico': 'library.ico',
  17.     'tray-ico-updating': 'systray_updating.ico',
  18.     'tray-ico-active': 'systray_active.ico',
  19.     'tray-ico-balloon': 'systray_balloon.ico',
  20.     'logo': 'gui_logo.png',
  21.     'mail-icon-ham': 'mail_ham.png',
  22.     'mail-icon-unsure': 'mail_unsure.png',
  23.     'mail-icon-spam': 'mail_spam.png',
  24.     'mail-icon-white': 'mail_white.png',
  25.     'mail-icon-black': 'mail_black.png',
  26.     'ham-normal': 'notspam.png',
  27.     'unsure-normal': 'unsure.png',
  28.     'spam-normal': 'spam.png',
  29.     'whitelist-normal': 'whitelist.png',
  30.     'blacklist-normal': 'blacklist.png',
  31.     'help-icon': 'questionmark.png' }
  32.  
  33. def get_image_filename(image_name, locale = 'en'):
  34.     """Return full path to image or False if it is unknown.
  35.  
  36.     We look first in the user's data directory, then in the locale
  37.     directory, then fall back to the global images directory.
  38.     """
  39.     
  40.     try:
  41.         image_file = images[image_name]
  42.     except KeyError:
  43.         return False
  44.  
  45.     image_folder = os.path.join(application_directory(), 'images')
  46.     data_dir = shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, 0, 0)
  47.     for directory in (os.path.join(data_dir, options[('Storage', 'user_data_dir')]), os.path.join(get_locale_dir(), locale), image_folder):
  48.         image_fullpath = os.path.join(directory, image_file)
  49.         if os.path.exists(image_fullpath):
  50.             return image_fullpath
  51.             continue
  52.     
  53.     return False
  54.  
  55.  
  56. def application_directory():
  57.     '''Convenience function.'''
  58.     if hasattr(sys, 'frozen'):
  59.         return os.path.dirname(sys.executable)
  60.     
  61.     return os.path.dirname(os.path.dirname(__file__))
  62.  
  63.  
  64. def get_locale_dir():
  65.     return os.path.join(application_directory(), 'locale')
  66.  
  67.